﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClientInfrastructure.Config
{

    public class AppConfigModel
    {
        public void SetConfigValue(string key, string value)
        {
            Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            cfa.AppSettings.Settings[key].Value = value;
            cfa.Save();
        }


        string? _ApiServer;

        public string? ApiServer
        {
            get
            {
                if (_ApiServer == default)
                    _ApiServer = ConfigurationManager.AppSettings["ServerUrl"];
                return _ApiServer;
            }
        }


        string? _Token;
        public string? Token
        {
            get
            {
                if (_Token == default)
                {
                    _Token = ConfigurationManager.AppSettings["Token"];
                }

                return _Token;
            }
            set => _Token = value;
        }

        string? _UserName;
        public string? UserName
        {
            get
            {
                if (_UserName == default)
                    _UserName = ConfigurationManager.AppSettings["UserName"];
                return _UserName;
            }
            set
            {
                _UserName = value;
            }
        }

        string? _Password;
        public string? Password
        {
            get
            {
                if (_Password == default)
                    _Password = ConfigurationManager.AppSettings["Password"];
                return _Password;
            }
            set
            {
                _Password = value;
            }
        }

    }

}
